Skip to content

fix(security): security batch to staging - #257

Merged
manager merged 3 commits into
devfrom
fix/security-batch-staging
Nov 11, 2026
Merged

manager merged 3 commits into
devfrom
fix/security-batch-staging

Conversation

@manager

@manager manager commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

The three commits of #256 on top of the staging branch: raster-only cover proxy, sanitised UX Core markup, certificate page fixes, style filter that refuses CSS escapes, accordion file limited to a CMS path.

Rollout to staging authorized by Wolf on 2026-11-11.

🤖 Generated with Claude Code

manager and others added 3 commits November 11, 2026 10:22
…tificate page crash

- Cover proxy answers only raster image types and sends nosniff plus a
  sandboxing content policy, so it cannot serve active content from our origin.
- UX Core content goes through an allowlist sanitiser after raw HTML parsing.
- Certificate page no longer crashes when the visitor context is not loaded;
  the user name is encoded in the request path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ing certificate answers 404

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…be a CMS path

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Claude finished @manager's task in 26s —— View job


Review of PR #257 (security batch to staging)

  • Read the diff against origin/dev
  • Checked the sanitiser schema against how useContentType renders the tags
  • Posted inline comments

Summary

Most of the batch is sound, but the sanitiser still has one XSS hole. I'd fix it before it reaches staging. I only read the code; I ran no build, lint or tests.

Needs a fix

  • ContentParser.tsx: the url attribute on <download> and <trello> is not validated. The protocols.url entry in the schema does nothing, because rehype-sanitize only checks href, src, cite and longDesc. useContentType puts url straight into <a href>, so javascript: links can still be injected through persona text. An inline comment has a suggested fix.

Minor

  • Import order was changed in certificate.tsx, ContentParser.tsx and useContentType.tsx against the AGENTS.md convention. Run eslint --fix to restore it.

Looks good

  • The cover proxy now allows only an allowlist of raster types, normalises the content-type header (it strips parameters), and sets nosniff plus a sandbox CSP.
  • The file attribute is restricted to a single-slash path.
  • The style filter blocks backslash escapes.
  • The certificate page no longer crashes when uxcatUserInfo is missing, and it returns a real 404 status.
  • The username is URL-encoded in getCertificate.
  • img with an untrusted source now renders nothing instead of crashing.

No UX Core bias data, slugs or schema are touched.

},
protocols: {
...defaultSchema.protocols,
url: ['http', 'https'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XSS gap: download / trello url is not validated. protocols in rehype-sanitize only applies to href, src, cite and longDesc. A url key does nothing here, so url on <download> and <trello> passes through unchecked. useContentType.tsx renders it as <a href={url}> (lines 117 and 133), so <trello url="javascript:alert(1)">x</trello> in persona text becomes a clickable javascript: link. Inside accordions the string is rebuilt and sanitised again, with the same result.

Add a pattern for the two tags, like the one used for file:

const SAFE_URL = /^(https?:\/\/|\/(?![\/\\]))/i;
// ...
download: [['url', SAFE_URL]],
trello: [['url', SAFE_URL]],

You can then drop the url entry from protocols, which is a no-op.

@@ -12,6 +8,9 @@ import {
Span,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import reorder in this file, in ContentParser.tsx and in certificate.tsx goes against the AGENTS.md import order: third-party first, then aliases grouped, then relative imports, then styles. It looks like an auto-sort with the wrong config. Run eslint --fix with the repo config to restore the order. It also makes the diff harder to review.

@manager

manager commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions.

  • download / trello url: disproved. The sanitiser applies the protocols map to any property named in it. Run against this schema, a url of javascript:, data: and a tab-split javascript: all come back removed; http, https and site paths stay.
  • Import order: disproved. ESLint with the repository config reports no errors on the three files; the order in the diff is the one simple-import-sort produced.

@manager
manager merged commit 7cb8d8c into dev Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant